﻿#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int add(int x, int y)
{
	return x + y;
}
int sub(int x, int y)
{
	return x - y;
}
int mul(int x, int y)
{
	return x * y;
}
int div(int x, int y)
{
	return x / y;
}
void menu()
{
	printf("*****************************\n");
	printf("********1.add 2.sub**********\n");
	printf("********3.mul 4.div**********\n");
	printf("********0.exit***************\n");
	printf("*****************************\n");
}
int (*p[5])(int x, int y) = { 0,add,sub,mul,div };
int main()
{
	int input;
	do
	{
		menu();
		printf("请选择:\n");
		scanf("%d", &input);
		int x, y;
		if (input >= 1 && input <= 4)
		{
			printf("请输入两个数：\n");
			scanf("%d%d", &x, &y);
			printf("%d\n", (*p[input])(x, y));
		}
		else if (input == 0)
		{
			printf("退出游戏！\n");
		}
		else
		{
			printf("选择错误，请重新选择！\n");
		}
	} while (input);
	return 0;
}